<!-- Phan khai bao bien cuc bo-->
<?php

$v_move_to_leader_status = $arr_single_recordtype['C_MOVE_TO_LEADER'];
//lay id cua nguoi dang nhap
$v_staff_id =  $_SESSION['staff_id'];
if(isset($_REQUEST['fuseaction_back'])) {
	$fuseaction_back=$_REQUEST['fuseaction_back'];
}else{
	$fuseaction_back = $fuseaction;
}

$v_fuseaction_onclick = 'DISPLAY_ALL_RECORD_WORK';
$v_goto_url = 'index.php';

$v_goto_url = "index.php";
$v_current_style_name = "round_row";
$v_receiver_id = $_SESSION['staff_id'];

//$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
// xac dinh label hien thi: trinh ky, duoc giai quyet, khong duoc giai quyet
$arr_result_label = onegate_get_label_of_result_type($_SESSION['recordtype'],$v_recordtype_filter);
$v_check_recordtype = onegate_get_check_recordtype($_SESSION['recordtype'],$v_recordtype_filter);
$v_count = sizeof($arr_all_record);
$v_delete_record = 0;

//echo onegate_get_handle_agency_id($_SESSION['recordtype'],$v_recordtype_filter);
for($i=0; $i<$v_count; $i++){
	if ($arr_all_record[$i]['FK_RECEIVER'] == $v_receiver_id){
		$v_delete_record = $v_delete_record + 1;
	}
}
echo $v_xml_file_list;
if (is_null($v_xml_file_list) || $v_xml_file_list==""){
	$v_file_list = "danh_sach_ho_so_da_tim.xml";
}else{
	$v_file_list = $v_xml_file_list;
}
//file dinh dang bang hien thi danh sach ho so da tiep nhan
$v_table_struct_xml_file = "../xml/".$v_recordtype_filter."/".$v_file_list;
//echo $v_table_struct_xml_file;
if (file_exists($v_table_struct_xml_file)){
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	
}else{
	$v_table_struct_xml_file = "../xml/search/".$v_file_list;
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
}
//echo $v_table_struct_xml_file;
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'col';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
?>
<!--bang chua tieu de cua form-->
<!-- bang chua cac tieu thuc loc-->
<!--
	Doan ma nay dung de hien thi cac duong link tuong ung voi cac nut o duoi man hinh danh sach
	Vi du: duong link "Them" tuong ung voi nut "Them" o duoi
-->
<!--Table chua cac button-->
<!--Het phan dia chi link-->
<!--Bat dau cong xau html de in danh sach du lieu-->
<?php
$v_html_string = '';
//$v_html_string = $v_html_string  . '<form action="index.php" method="post" name="f_dsp_all_record">';
$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
$v_html_temp_width = '';
$v_html_temp_label = '';
$v_column = 0;
$array_pos_hide_column = array(); //vtri cac cot bi an di ... de in ra cac dong trang ...

while ($table_struct_rec) { 
	$table_struct_row = $table_struct_rec->getRow();
	$v_label = $table_struct_row["label"];
	$v_width = $table_struct_row["width"];
	$v_recordtype_list_2 = $table_struct_row["list"];
	
	$arr_recordtype_list_2 = explode(",",$v_recordtype_list_2);
//	var_dump($arr_recordtype_list_2);
	
		$style2 = '';
		if( $v_recordtype == "All")
			$style2 = "display:block";
		else
		{
			if( $v_recordtype_list_2 == "All")
				$style2 = "display:block";
			else
			{
				if(in_array($v_reporttype_filter,$arr_recordtype_list_2))
					$style2 = "display:block";	
				else
				{
					$style2 = "display:none";
					$array_pos_hide_column[] = $v_column;
				}	
			}
		}
//	echo $v_label.'/'.$v_recordtype.'/'.$v_recordtype_list_2.'/'.$style2.'<br/>';
		
	$v_html_temp_width = $v_html_temp_width  . '<col width="'.$v_width .'">';
	$v_html_temp_label = $v_html_temp_label . '<td style="'.$style2.'" align="center">'.$v_label.'</td>';
	$table_struct_rec = $table_struct_rax->readRecord();
	$v_column ++;
}

$v_html_string = $v_html_string  . $v_html_temp_width;
$v_html_string = $v_html_string  . '<tr class="header">';
$v_html_string = $v_html_string  . $v_html_temp_label;
$v_html_string = $v_html_string  . '</tr></table>';
//$v_html_string = $v_html_string  . '<div style="overflow: auto; width: 100%; height:'._CONST_HEIGHT_OF_LIST.';padding-left:0px;margin:0px">';
$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
$v_html_string = $v_html_string  . $v_html_temp_width;
	if ($v_count >0){
		for($row_index = 0;$row_index< $v_count ;$row_index++){
			$v_url = "";
			$v_received_record_xml_data = $arr_all_record[$row_index]['C_RECEIVED_RECORD_XML_DATA'];
			//echo htmlspecialchars($v_received_record_xml_data);
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			$v_html_string = $v_html_string  .'<tr class="'.$v_current_style_name.'" >'; 
			$table_struct_rax = new RAX(); 
			$table_struct_rec = new RAX(); 
			$table_struct_rax->open($v_table_struct_xml_string);
			$table_struct_rax->record_delim = 'col';
			$table_struct_rax->parse();
			$table_struct_rec = $table_struct_rax->readRecord(); 
			while ($table_struct_rec) { 
				$table_struct_row = $table_struct_rec->getRow();
				$v_type = $table_struct_row["type"];
				$v_width = $table_struct_row["width"];
				$v_recordtype_list_3 = $table_struct_row["list"];
				$v_align = $table_struct_row["align"];
				$v_xml_data = $table_struct_row["xml_data"];
				$v_column_name = $table_struct_row["column_name"];
				//echo 'v_column_name'.$v_column_name.'<br>';
				$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db"];
				$v_php_function = $table_struct_row["php_function"];
				$v_selectbox_option_sql = $table_struct_row["selectbox_option_sql"];
				
				$arr_recordtype_list_3 = explode(",",$v_recordtype_list_3);
				$style3 = '';
				if( $v_recordtype == "All")
					$style3 = "display:block";
				else{
					if( $v_recordtype_list_3 == "All")
						$style3 = "display:block";
					else{
						if(in_array($v_reporttype_filter,$arr_recordtype_list_3))
							$style3 = "display:block";	
						else
							$style3 = "display:none";
					}
				}
				
				if ($v_xml_data=="true"){
					$column_rax = new RAX(); 
					$column_rec = new RAX();
					$column_rax->open($v_received_record_xml_data);
					$column_rax->record_delim = 'data_list';
					$column_rax->parse();
					$column_rec = $column_rax->readRecord(); 
					$column_row = $column_rec->getRow();
					$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);
					$v_html_string = $v_html_string  . Element_Type($v_type,$style3); 
				}else{
					$v_value = $arr_all_record[$row_index][$v_column_name];
					if ($v_type=="checkbox"){
						$v_value_id = $arr_all_record[$row_index][$v_column_name];
							if($v_recordtype_filter=="All"){
								$v_url = "row_onclick_all(" . "document.forms[0].hdn_record_id"  . "," . $v_value_id . "," . "'".$v_fuseaction_onclick."','" . $v_goto_url . "','".$arr_all_record[$row_index][FK_RECORDTYPE]."')";
							}
							else
								$v_url = "row_onclick(" . "document.forms[0].hdn_record_id"  . "," . $v_value_id . "," . "'".$v_fuseaction_onclick."','" . $v_goto_url . "')";
					}
					$v_html_string = $v_html_string  . Element_Type($v_type,$style3); 
				}
				$table_struct_rec = $table_struct_rax->readRecord();
			}
			$v_html_string = $v_html_string  .'</tr>';
		}
	}
	if ($v_current_style_name == "odd_row"){
		$v_next_style_name = "round_row";
	}else{
		$v_next_style_name = "odd_row";
	}
//$array_pos_hide_column = explode(",",$v_pos_hide_column);

$v_html_string = $v_html_string  . _add_empty_row($v_count,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,$v_column,$array_pos_hide_column);

//$v_html_string = $v_html_string  .'</table></div>';
$v_html_string = $v_html_string  .'</table>';
echo $v_html_string;
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td height="5pt"></td></tr>
	<tr><?php
		if ($v_count>0){?>
			<td align="left" colspan = "2" class="small_label">
				<small class="small_starmark"><?php echo CONST_RECORD_COUNT_LIST_LABEL1 . $v_count . CONST_RECORD_COUNT_LIST_LABEL2;?></small>
			</td><?php
			if ($v_worktype!=""){?>
				<td class="normal_label" align="right">
					<input type="radio" name="rad_selectall" value="0" onClick="select_all_checkbox(document.forms[0],'chk_item_id');"><?php echo CONST_RECORD_SELECT_ALL_LABEL?>
					<input type="radio" name="rad_selectall" value="1" checked onClick="deselect_all(document.forms[0],'chk_item_id');"><?php echo CONST_RECORD_DESELECT_ALL_LABEL?>
				</td><?php
			}
		}else{?>
			<td align="left" colspan = "2" class="small_label">
				<small class="small_starmark"><?php echo CONST_RECORD_COUNT_LIST_LABEL;?></small>
			</td><?php
		}?>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<col width="5%"><col width="95%">
	<tr>
		<td align="right" class="normal_link"><? 
			if ($v_count >0){
				echo onegate_pagebreak_selectbox($v_total_record,$v_page,$v_limit_row,$fuseaction) ."&nbsp;". onegate_change_record_number_page($v_limit_row,$fuseaction);
			}
			?>
		</td>
	</tr>
</table><!--Table chua cac button-->
</div id="hotkey">
</form> 